﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HPKaraoke
{
    /// <summary>
    /// Interaction logic for ucLyricDisplayControl.xaml
    /// </summary>
    public partial class ucLyricDisplayControl : UserControl
    {
        public ucLyricDisplayControl()
        {
            InitializeComponent();
            
            
        }

        private static void SetMarginS(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as ucLyricDisplayControl).SetMargin((Thickness)e.NewValue);
        }

        private void SetMargin(Thickness thickness)
        {
            this.BackgroundText.Margin = thickness;
            this.AnimationText.Margin = thickness;
        }

        public Thickness LyricMargin 
        {
            get
            {
                return (Thickness)GetValue(LyricMarginProperty);
            }
            set 
            {
                SetValue(LyricMarginProperty, value);
            }
        }

        public static readonly DependencyProperty LyricMarginProperty = DependencyProperty.Register(
            "LyricMargin",
            typeof(Thickness),
            typeof(ucLyricDisplayControl),
            new PropertyMetadata(new Thickness(0,0,0,0),
                new PropertyChangedCallback(SetMarginS)
                )
            );

        private static void ChangeFontSizeS(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as ucLyricDisplayControl).ChangeFontSize((double)e.NewValue);
        }

        private void ChangeFontSize(double p)
        {
            this.BackgroundText.FontSize = this.AnimationText.FontSize = p;
        }

        public static readonly DependencyProperty LyricFontSizeProperty = DependencyProperty.Register(
            "LyricFontSize",
            typeof(double),
            typeof(ucLyricDisplayControl),
            new PropertyMetadata(
                (double)64,
                new PropertyChangedCallback(ChangeFontSizeS)
                )
            );

        public double LyricFontSize 
        {
            get
            {
                return (double)GetValue(LyricFontSizeProperty);
            }
            set
            {
                SetValue(LyricFontSizeProperty, value);
            }
        }


        private static void ChangeFontS(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as ucLyricDisplayControl).ChangeFont((FontFamily)e.NewValue);
        }

        private void ChangeFont(FontFamily p)
        {
            this.BackgroundText.Font = this.AnimationText.Font = p;
        }

        public static readonly DependencyProperty FontProperty = DependencyProperty.Register(
            "Font",
            typeof(FontFamily),
            typeof(ucLyricDisplayControl),
            new PropertyMetadata(
                new FontFamily("Tahoma"),
                new PropertyChangedCallback(ChangeFontS)
                )
            );

        public FontFamily Font
        {
            get
            {
                return (FontFamily)GetValue(FontProperty);
            }
            set
            {
                SetValue(FontProperty, value);
            }
        }

    }
}
